import { NextResponse } from 'next/server'
import { RateLimiter } from 'limiter'
import { maxRequestLimit } from '../configs/index'
const limiter = new RateLimiter({
  tokensPerInterval: maxRequestLimit,
  interval: 'min',
  fireImmediately: true,
})

export async function limitMiddleware(
  request: Request,
  next: () => Promise<NextResponse>
): Promise<NextResponse> {
  console.log('Limit Middleware:', request.url)
  // 实现限流逻辑
  return next()
}

export const limitMatcher = ['/api/limit/:path*']
